﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using uzing;

namespace example_tcp_client
{
    class Program_client
    {
        static void Main(string[] args)
        {
            uzCTcpClientSync client = new uzCTcpClientSync();
            client.ConnectToServer("localhost", 9000);

            int dataSize = 1024;
            byte[] Buffer = new byte[1024];
            ASCIIEncoding encoder = new ASCIIEncoding();

            string message = "test message # ";
            int index = 0;

            if (null != client)
            {
                while (true)
                {
                    string msg = message + index.ToString();
                    index++;
                    byte[] tmpBuf = encoder.GetBytes(msg);
                    tmpBuf.CopyTo(Buffer, 0);
                    client.SendData(Buffer, 0, dataSize);
                    System.Threading.Thread.Sleep(100);
                }
            }
            else
            {
                System.Console.WriteLine("Connection Error");
            }
        }
    }
}
